<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="/js/axios.min.js"></script>
<script src="/js/util.js"></script>
<script>
    var channelId;
    window.onload = function () {
        channelId = getQuery("channelId");
    }
    function addPost() {
        axios.get("/post/add", {
            params: {
                channelId,
                title: $("titleText").value,
                content: $("contentText").value
            }
        }).then(resp => {
            if (resp.data == "ok") {
                location.href="/post.html?channelId="+channelId;
            }
        })
    }

    function resetForm() {
        $("titleText").value = null;
        $("contentText").value = null;
    }

    function back(){
        location.href="/post.html?channelId="+channelId;
    }

</script>
<body>
标题：<input type="text" id="titleText"><br>
内容：<textarea id="contentText"></textarea><br>
<input type="button" value="发表" onclick="addPost()">
<input type="button" value="重置" onclick="resetForm()">
<input type="button" value="返回" onclick="back()">
</body>
</html>